<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<style>
.form-item {
	margin: 20px 10px;
}

.form-item>label {
	letter-spacing: 3px;
	width: 110px;
	text-align: right;
	display: inline-block;
}

.form-item>label:after {
	content: ":";
}

.form-item input[type=text] {
	width: 100px;
}

.form-item.required>label:before {
	content: "*";
	color: red;
}
</style>
<form id="resourceForm">
	<input type="hidden" name="resourceId" value="${resources.resourceId}">
		<div style="margin-top: 20px;" class="form-item">
			<label for="">父资源</label> <select id="parent_" name="parent" style="width: 200px;"
				class="easyui-combotree"
				data-options="editable:false,panelHeight:'300',url:'resource/manager/combo',value:'${not empty resources and not empty resources.parent  ? resources.parent.resourceId : '请选择'}'"></select>
			<label for="">资源名称</label> <input name="resourceName" type="text" style="width: 150px;"
				class="easyui-textbox" data-options="required:true"
				value="${resources.resourceName}">
		</div>
		<div class="form-item required" >
				<label for="">资源类型</label> <select name="type" id="type"
				class="easyui-combobox" style="width: 200px;"
				data-options="editable:false,panelHeight:'auto',value:'${resources.type==null?'MENU':resources.type}'">
				<option value="MENU">菜单</option>
				<option value="FUNCTION">功能</option>
				<option value="BLOCK">区域</option>
			</select>
			<label for="">资源标识</label> <input name="permissionKey" type="text"
				class="easyui-textbox" data-options="required:true" style="width: 150px;"
				value="${resources.permissionKey}">
		</div>
		<div class="form-item" >
				<label for="" style="margin-right: 10px">权重</label> <input name="weight" style="width: 100px;"
					class="easyui-numberbox" value="${resources.weight}">
					<c:if test="${empty resources}">
							<label style="margin-left: -15px;" for="">菜单路径</label> <input type="text" name="menuPath"
							
								id="menuPath" class="easyui-textbox" value="${resources.menuPath}">
					</c:if>
					<c:if test="${not empty resources and not empty resources.type and resources.type == 'MENU'}">
							<label style="margin-left: -15px;" for="">菜单路径</label> <input type="text" name="menuPath"
								id="menuPath" class="easyui-textbox" value="${resources.menuPath}">
					</c:if>
					<c:if test="${not empty resources and not empty resources.type and resources.type != 'MENU'}">
							<label  style="margin-left: -15px;" for="">菜单路径</label> <input type="text" name="menuPath"
								id="menuPath" class="easyui-textbox" value="${resources.menuPath}" readonly="readonly">
					</c:if>
					<label  style="margin-left: -40px;" for="">状态</label> <input id="resources-enable" name="enable"
					class="easyui-switchbutton"
					data-options="onText:'启用',offText:'禁用',checked:${not empty resources and resources.enable == false ? 'false' : 'true' }">
				<input type="hidden"
					value="${not empty resources and resources.enable == false ? 0 : 1 }"
					id="enable_" name="enable">
			</div>
			
		<div class="form-item" >
			<label for="">资源</label><br><span style="margin-left: 110px;"></span> <input type="text" name="resource"
				class="easyui-textbox" data-options="multiline:true"
				style="height: 70px;width:250px;" value="${resources.resource}">
		</div>

		<div class="form-item"">
			<label for="">描述</label><br><span style="margin-left: 110px;"></span>  <input name="description" type="text"
				class="easyui-textbox" data-options="multiline:true"
				style="height: 70px;width:250px;"  value="${resources.description}">
		</div>
</form>
<script type="text/javascript">
	$(function() {
		$('#resources-enable').switchbutton({
			onChange : function(checked) {
				if (checked == true) {
					$("#enable_").val("1");
					return;
				}
				if (checked == false) {
					$("#enable_").val("0");
					return;
				}
			}
		})
		$("#type").combobox({
		onChange : function(n, o) {// n:value值;o:上一个option的value值;
			if (n != 'MENU') {
				$("#menuPath").textbox('textbox').attr('readonly',true); 
				$("#menuPath").textbox('setValue',""); 
			} else {
				$("#menuPath").textbox('textbox').attr('readonly',false); 
			}
		}
		});
	});
</script>